package com.itheima.Controller;

import com.itheima.Service.SetmealService;
import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/setmeal")
public class SetmealConreoller {
    @Autowired
    private SetmealService setmealService;
    /**
     * 获取所有套餐信息
     */
   @PostMapping("/getSetmeal")
    public Result listsetmeal(){
        log.info("用户端查询套餐");
        List<Setmeal> ARR =setmealService.llistsetmeal();
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,ARR);
    }
    /**
     * 查询根据套餐id查询套餐详情
     */
    @PostMapping("/findById")
    public Result<Setmeal> liist(Integer id){
        log.info("查询套餐信息;{}",id);
        Setmeal setmeal=setmealService.list(id);
        return new Result<>(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
    }
}
